<?php

namespace app\serversms\service\sms;
use app\manage\service\ApiBase;

/**
 * @author:      李颖
 * @DateTime:    2017-06-26 15:36:25
 * @Description: 短信验证码类
 */

class Verify extends ApiBase
{
	
	protected $verifyLogic = 'app\serversms\logic\Verify';
    protected $verifyValidate = 'app\serversms\validate\Verify';
    protected $sendField = ['code_id'=>0,'mobile'=>' ','token'=>' ','type'=>' ','sms_info'=>[]];
    protected $checkField = ['mobile'=>' ','token'=>' ','type'=>' ','verify'=>0,'code_id'=>0];
   
    /*发送短信验证码*/
    public function sendVerify(): array 
    {

        $data = $this->receiveData($this->sendField);

        $validate = validate($this->verifyValidate);
        if(!$validate->check($data)){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('smsInfo')->check($data['sms_info'])){ return verify_err(null, $validate->getError()); }

        return $this->logic($this->verifyLogic)->sendVerify($data);
    }

    /*验证短信验证码*/
    public function checkVerify(): array 
    {
        $data = $this->haveIssetReceiveData($this->checkField);
        return $this->stepRun($data, 'checkVerify');

    }


}
